<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<title>Exported from Notepad++</title>
<style type="text/css">
span {
	font-family: 'Courier New';
	font-size: 10pt;
	color: #000000;
}
.sc0 {
}
.sc2 {
	font-style: italic;
	color: #0000FF;
}
.sc4 {
	color: #8000FF;
}
.sc5 {
	font-weight: bold;
	font-style: italic;
	color: #0000FF;
}
.sc6 {
	font-weight: bold;
	color: #008000;
}
.sc8 {
	font-weight: bold;
	font-style: italic;
	color: #008000;
}
.sc10 {
	font-weight: bold;
	color: #0080FF;
}
.sc11 {
}
</style>
</head>
<body>
<div style="float: left; white-space: pre; line-height: 1; background: #FFFFFF; "><span class="sc2">// ================================================== //</span><span class="sc0">
</span><span class="sc2">// ============ TUTORIELS BEBOP 1.0 ================= //</span><span class="sc0">
</span><span class="sc2">// ================================================== //</span><span class="sc0">

</span><span class="sc2">// Optimisation : on ne fixe pas le resultat de la division par 0</span><span class="sc0">

</span><span class="sc10">#</span><span class="sc5">intargv</span><span class="sc0"> </span><span class="sc8">N</span><span class="sc0"> 

</span><span class="sc10">#</span><span class="sc6">init</span><span class="sc0"> </span><span class="sc10">%{</span><span class="sc0">

    </span><span class="sc11">let</span><span class="sc0"> </span><span class="sc11">t</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc11">ref</span><span class="sc0"> </span><span class="sc4">0</span><span class="sc10">;;</span><span class="sc0">
    </span><span class="sc11">let</span><span class="sc0"> </span><span class="sc11">num_addr</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc4">2</span><span class="sc0"> </span><span class="sc10">$$</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc4">2</span><span class="sc0"> </span><span class="sc11">*</span><span class="sc0"> </span><span class="sc11">_N</span><span class="sc10">);;</span><span class="sc0">
    
    </span><span class="sc11">let</span><span class="sc0"> </span><span class="sc11">tmp_s</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">Array</span><span class="sc10">.</span><span class="sc11">make</span><span class="sc0"> </span><span class="sc11">_N</span><span class="sc0"> </span><span class="sc11">false</span><span class="sc10">;;</span><span class="sc0">
    </span><span class="sc11">let</span><span class="sc0"> </span><span class="sc11">etoile</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">String</span><span class="sc10">.</span><span class="sc11">make</span><span class="sc0"> </span><span class="sc11">_N</span><span class="sc0"> </span><span class="sc11">'*'</span><span class="sc10">;;</span><span class="sc0">   

    </span><span class="sc10">(</span><span class="sc11">*</span><span class="sc0"> </span><span class="sc11">print</span><span class="sc0"> </span><span class="sc11">s</span><span class="sc0"> </span><span class="sc10">&lt;-</span><span class="sc0"> </span><span class="sc11">a/b</span><span class="sc0"> </span><span class="sc11">*</span><span class="sc10">)</span><span class="sc0">
    </span><span class="sc11">let</span><span class="sc0"> </span><span class="sc11">div_opt_fct</span><span class="sc0"> </span><span class="sc11">a</span><span class="sc0"> </span><span class="sc11">b</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0">
        </span><span class="sc11">let</span><span class="sc0"> </span><span class="sc11">int_a</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">BoolArray</span><span class="sc10">.</span><span class="sc11">to_int</span><span class="sc0"> </span><span class="sc11">a</span><span class="sc0"> </span><span class="sc11">in</span><span class="sc0">
        </span><span class="sc11">let</span><span class="sc0"> </span><span class="sc11">int_b</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">BoolArray</span><span class="sc10">.</span><span class="sc11">to_int</span><span class="sc0"> </span><span class="sc11">b</span><span class="sc0"> </span><span class="sc11">in</span><span class="sc0">
        </span><span class="sc5">if</span><span class="sc0"> </span><span class="sc11">int_b</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc4">0</span><span class="sc0">
        </span><span class="sc5">then</span><span class="sc0"> </span><span class="sc11">print_endline</span><span class="sc0"> </span><span class="sc11">etoile</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">*</span><span class="sc0"> </span><span class="sc11">bits</span><span class="sc0"> </span><span class="sc11">don't</span><span class="sc0"> </span><span class="sc11">care</span><span class="sc0"> </span><span class="sc11">*</span><span class="sc10">)</span><span class="sc0">
        </span><span class="sc5">else</span><span class="sc0"> 
            </span><span class="sc11">begin</span><span class="sc0">
                </span><span class="sc8">BoolArray</span><span class="sc10">.</span><span class="sc11">load_of_int</span><span class="sc0"> </span><span class="sc11">tmp_s</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">int_a</span><span class="sc0"> </span><span class="sc11">/</span><span class="sc0"> </span><span class="sc11">int_b</span><span class="sc10">);</span><span class="sc0">
                </span><span class="sc11">print_endline</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc8">BoolArray</span><span class="sc10">.</span><span class="sc11">to_string</span><span class="sc0"> </span><span class="sc11">tmp_s</span><span class="sc10">)</span><span class="sc0">
            </span><span class="sc5">end</span><span class="sc10">;;</span><span class="sc0">
</span><span class="sc10">}%</span><span class="sc0">

</span><span class="sc10">#</span><span class="sc11">main</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">a</span><span class="sc10">:[</span><span class="sc8">N</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">b</span><span class="sc10">:[</span><span class="sc8">N</span><span class="sc10">])</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc11">?</span><span class="sc0">
</span><span class="sc10">#</span><span class="sc5">with</span><span class="sc0"> </span><span class="sc5">code</span><span class="sc0"> </span><span class="sc10">%{</span><span class="sc0">
    </span><span class="sc5">if</span><span class="sc0"> </span><span class="sc11">!t</span><span class="sc0"> </span><span class="sc10">&gt;=</span><span class="sc0"> </span><span class="sc11">num_addr</span><span class="sc0"> </span><span class="sc5">then</span><span class="sc0"> </span><span class="sc11">exit</span><span class="sc0"> </span><span class="sc4">0</span><span class="sc0"> </span><span class="sc5">else</span><span class="sc0">
    </span><span class="sc11">begin</span><span class="sc0">
        </span><span class="sc11">incr</span><span class="sc10">(</span><span class="sc11">t</span><span class="sc10">);</span><span class="sc0"> 
        </span><span class="sc11">div_opt_fct</span><span class="sc0"> </span><span class="sc11">a</span><span class="sc0"> </span><span class="sc11">b</span><span class="sc0">
    </span><span class="sc5">end</span><span class="sc0">
</span><span class="sc10">}%</span><span class="sc0">
</span></div></body>
</html>
